<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .p01{
            width:200px;
            height:100px;
            background-color:green;
        }
    </style>
</head>

<body>
    <div id="box">

    </div>
  
    <script src="./js/react18.js"></script>
    <script src="./js/react-dom18.js"></script>
    <script src="./js/babel.min.js"></script>
    
    <script type="text/babel">

        // 创建一个根对象：
        let root = ReactDOM.createRoot(document.getElementById("box"));

        const  age = 20;

        const ShowIsAdult = ()=>{
            if(age<18){
                return <p>未成年</p>;
            }else{
                return <p>已成年</p>;
            }
        }
        
        const jsx = (<div>
                        <h2>标题2：</h2>
                        是否成年：
                        {ShowIsAdult()}
                        <hr/>
                    </div>);
        
        console.log("jsx",jsx);//jsx就是虚拟dom


        // 把jsx渲染到根对象对应的dom容器里
        root.render(jsx);
        

    </script>
</body>

</html>